package fdts.test;

import ieg.prefuse.data.DataHelper;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;

import timeBench.calendar.Calendar;
import timeBench.calendar.CalendarManager;
import timeBench.calendar.CalendarManagerFactory;
import timeBench.calendar.CalendarManagers;
import timeBench.calendar.Granularity;
import timeBench.calendar.Granule;
import timeBench.calendar.JavaDateCalendarManager;
import timeBench.data.GenericTemporalElement;
import timeBench.data.TemporalDataException;
import timeBench.data.TemporalDataset;
import timeBench.data.TemporalElement;
import timeBench.data.TemporalObject;
import timeBench.data.io.GraphMLTemporalDatasetReader;
import timeBench.data.io.GraphMLTemporalDatasetWriter;
import timeBench.data.io.TemporalDatasetReader;
import timeBench.data.util.IntervalIndex;
import prefuse.Visualization;
import prefuse.data.Node;
import prefuse.data.expression.ColumnExpression;
import prefuse.data.expression.ComparisonPredicate;
import prefuse.data.expression.NumericLiteral;
import prefuse.data.expression.parser.ExpressionParser;
import prefuse.data.io.DataIOException;
import prefuse.util.collections.IntIterator;
import prefuse.visual.VisualGraph;

class myImporter implements TemporalDatasetReader{

	public myParser parser;
	
	public myImporter(){
		parser = new myParser();
	}
	
	@Override
	public TemporalDataset readData(String arg0) throws DataIOException,
			TemporalDataException {
		System.out.println( "Is not implemented yet." );
		return null;
	}

	@Override
	public TemporalDataset readData(URL arg0) throws DataIOException,
			TemporalDataException {
		System.out.println( "Is not implemented yet." );
		return null;
	}

	@Override
	public TemporalDataset readData(File file) throws DataIOException,
			TemporalDataException {
		
		BufferedReader reader = null;
		if( file.getName().endsWith(".ics") ){
			try {
				
				reader = new BufferedReader ( new FileReader ( file ) );
				parser.parse (reader);
				
			} catch ( Exception ex ) {
				System.out.println(ex.getMessage());
			} finally{
				if(reader != null)
					try {
						reader.close();
					} catch (IOException ex) {
						ex.printStackTrace();
					}
			}
			
		} else
			System.out.println( "Error: supported file-format is ics!" );
		
		return null;
	}

	@Override
	public TemporalDataset readData(InputStream arg0) throws DataIOException,
			TemporalDataException {
		System.out.println( "Is not implemented yet." );
		return null;
	}
	
	public static void main(String[] args){
		File file = new File("ics/Work.ics");
		myImporter importer = new myImporter();
		try{
			importer.readData(file);
		} catch( Exception ex ){
			System.out.println( ex.getMessage() );
		}
	}
}